import { createRouter, createWebHashHistory } from 'vue-router';
import { onMounted } from 'vue';
import Layout from '@/views/Layout/Layout.vue';

import AboutView from '@/views/About/AboutView.vue';
import Login from '@/views/Login/Login.vue';
import Home from '@/views/Home/Home.vue';
import Register from '@/views/Register/Register.vue';
import StudentView from '@/views/Student/StudentView.vue';
import TeacherView from '@/views/Teacher/TeacherView.vue';

export const router = createRouter({
  history: createWebHashHistory(), // 使用默认的历史管理器
  // 路由滚动行为定制
  scrollBehavior() {
    return {
      top: 0
    }
  },
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        {
          path: '/',
          component: Home
        },
        {
          path: '/teacher',
          component: TeacherView
        },
        {
          path: '/student',
          component:StudentView
        },
        {
          path: '/chat',
          component: () => import('@/views/Student/Chatpage.vue')
        }
      ]
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/Register',
      component: Register
    },
    {
      path: '/about',
      component: AboutView
    },
    {
      path: '/test/chat',
      component: () => import('@/views/test/TestChatBox.vue')
    }
    ,
    {
      path: '/test/md',
      component: () => import('@/views/test/TestMarkDown.vue')
    }
  ],
});

onMounted(() => {
  // 如果有需要，可以在挂载后做一些初始化操作
});

export default router

